<template>
	<view>
		<web-view :src="pdfUrl"></web-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				busCode:"",//业务职能编码
				fileId:'',
				simpleClazzName:'',
				viewerUrl: '/static/pdfjs/web/viewer.html',
				fileUrl:"uploadFiles/getFile",
				allUrl: '',
				filePath:'',
				key:'',
				fileUplaodKey:'',
				pdfUrl:""
			}
		},
		methods:{
			getPdfUrl(){
				let _that = this;
				_that.om.request('uploadFiles/getFilePath', {
					 busCode: _that.busCode,
					 fileId: _that.fileId,
					 uploadFileKey: _that.fileUplaodKey
				}, 'get', false).then(res => {
					if (res.succeed) {
						_that.pdfUrl = `${_that.viewerUrl}?file=${encodeURIComponent(_that.om.getFilePath(res.value))}`;
					} else {
						_that.om.toast(res.msg);
					}
				});
			}
		},
		onLoad(options) {
			if(options.busCode){
				this.busCode = options.busCode
			}
			if(options.fileId){
				this.fileId = options.fileId
			}
			if(options.simpleClazzName){
				this.simpleClazzName = options.simpleClazzName
			}
			if(options.filePath){
				this.filePath = options.filePath
			}
			if(options.key){
				this.key = options.key
			}
			if(options.fileUplaodKey){
				this.fileUplaodKey = options.fileUplaodKey
			}
			this.getPdfUrl();
		}
	}
</script>

